package com.qf.electronic.mall.email.service.config;

import com.qf.constant.RabbitConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitmqConfig {

    @Bean
    public Queue getQueue(){
        return new Queue(RabbitConstant.EMAIL_SEND_QUEUE);

    }

    @Bean
    public TopicExchange getTopicExchange(){
        return new TopicExchange(RabbitConstant.EMAIL_TOPIC_EXCHANGE,false,false,null);
    }

    @Bean
    public Binding getBingding(Queue queue,TopicExchange topicExchange){
       return BindingBuilder.bind(queue).to(topicExchange).with("email.register");
    }

}
